﻿namespace NEvoWeb.Modules.NB_Store
{
    using DotNetNuke.Common.Utilities;
    using DotNetNuke.Entities.Modules;
    using DotNetNuke.Services.Exceptions;
    using DotNetNuke.Services.Localization;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections;
    using System.Reflection;
    using System.Runtime.CompilerServices;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public class ShipRates : BaseAdminModule
    {
        [AccessedThroughProperty("cmdAddCounty")]
        private LinkButton _cmdAddCounty;
        [AccessedThroughProperty("cmdDelete")]
        private LinkButton _cmdDelete;
        [AccessedThroughProperty("cmdNew")]
        private LinkButton _cmdNew;
        [AccessedThroughProperty("cmdSearch")]
        private LinkButton _cmdSearch;
        [AccessedThroughProperty("cmdUpdate")]
        private LinkButton _cmdUpdate;
        [AccessedThroughProperty("CompareValidator1")]
        private CompareValidator _CompareValidator1;
        [AccessedThroughProperty("ddlCategory")]
        private DropDownList _ddlCategory;
        [AccessedThroughProperty("ddlCountry")]
        private DropDownList _ddlCountry;
        [AccessedThroughProperty("ddlShipMethod")]
        private DropDownList _ddlShipMethod;
        [AccessedThroughProperty("grdRange")]
        private DataGrid _grdRange;
        [AccessedThroughProperty("lblCDefaultID")]
        private Label _lblCDefaultID;
        [AccessedThroughProperty("lblFreeShip")]
        private Label _lblFreeShip;
        [AccessedThroughProperty("lblPDefaultID")]
        private Label _lblPDefaultID;
        [AccessedThroughProperty("lblShipMethod")]
        private Label _lblShipMethod;
        [AccessedThroughProperty("plCDefault")]
        private UserControl _plCDefault;
        [AccessedThroughProperty("plFreeShip")]
        private UserControl _plFreeShip;
        [AccessedThroughProperty("plFreeShipList")]
        private UserControl _plFreeShipList;
        [AccessedThroughProperty("plPDefault")]
        private UserControl _plPDefault;
        [AccessedThroughProperty("plRangeHelp")]
        private UserControl _plRangeHelp;
        [AccessedThroughProperty("pnlCountry")]
        private Panel _pnlCountry;
        [AccessedThroughProperty("pnlEdit")]
        private Panel _pnlEdit;
        [AccessedThroughProperty("pnlFree")]
        private Panel _pnlFree;
        [AccessedThroughProperty("pnlProduct")]
        private Panel _pnlProduct;
        [AccessedThroughProperty("pnlRange")]
        private Panel _pnlRange;
        [AccessedThroughProperty("revCCDefault")]
        private CompareValidator _revCCDefault;
        [AccessedThroughProperty("revPCDefault")]
        private CompareValidator _revPCDefault;
        private int _ShipMethodID;
        private string _ShipType;
        [AccessedThroughProperty("txtCDefault")]
        private TextBox _txtCDefault;
        [AccessedThroughProperty("txtFreeShip")]
        private TextBox _txtFreeShip;
        [AccessedThroughProperty("txtFreeShipList")]
        private TextBox _txtFreeShipList;
        [AccessedThroughProperty("txtPDefault")]
        private TextBox _txtPDefault;
        [AccessedThroughProperty("txtSearch")]
        private TextBox _txtSearch;

        public ShipRates()
        {
            base.Load += new EventHandler(this.Page_Load);
        }

        private void AddNewRecord(int ObjectID, string Description)
        {
            ShipController controller = new ShipController();
            NB_Store_ShippingRatesInfo objInfo = new NB_Store_ShippingRatesInfo {
                ItemId = 0,
                ObjectId = ObjectID,
                Range1 = decimal.Zero,
                Range2 = decimal.Zero,
                ShipCost = decimal.Zero,
                ShipType = this._ShipType.ToUpper(),
                Description = Description,
                ProductWeight = decimal.Zero,
                ProductHeight = decimal.Zero,
                ProductLength = decimal.Zero,
                ProductWidth = decimal.Zero,
                PortalID = this.PortalId,
                ShipMethodID = this._ShipMethodID
            };
            controller.UpdateObjShippingRate(objInfo);
            SharedFunctions.UpdateLog(this.UserId, this.ControlName + " - " + MethodBase.GetCurrentMethod().Name + " - " + XmlUtils.Serialize(objInfo));
        }

        private void cmdAddCounty_Click(object sender, EventArgs e)
        {
            this.AddNewRecord(-1, this.ddlCountry.SelectedItem.Text);
            this.Response.Redirect(this.Request.Url.ToString());
        }

        private void cmdDelete_Click(object sender, EventArgs e)
        {
            this.deleteFDefault();
            this.Response.Redirect(this.EditUrl("smethod", this.GetSelectedShipMethod(), "ShipRates", new string[] { "spg=" + this._ShipType }), true);
        }

        private void cmdNew_Click(object sender, EventArgs e)
        {
            this.AddNewRecord(-1, "");
            this.Response.Redirect(this.Request.Url.ToString());
        }

        private void cmdSearch_Click(object sender, EventArgs e)
        {
            this.grdRange.CurrentPageIndex = 0;
            this.populateRangeDG();
        }

        private void cmdUpdate_Click(object sender, EventArgs e)
        {
            this.updateRangeDG();
        }

        private void ddlShipMethod_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.Response.Redirect(this.EditUrl("smethod", this.GetSelectedShipMethod(), "ShipRates", new string[] { "spg=" + this._ShipType }), true);
        }

        private void deleteFDefault()
        {
            ShipController controller = new ShipController();
            NB_Store_ShippingRatesInfo current = new NB_Store_ShippingRatesInfo();
            ArrayList list = controller.GetShippingRateList(this.PortalId, "FRE", SharedFunctions.GetCurrentCulture(), "", this._ShipMethodID);
            if (list != null)
            {
                IEnumerator enumerator=null;
                try
                {
                    enumerator = list.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        current = (NB_Store_ShippingRatesInfo) enumerator.Current;
                        controller.DeleteShippingRate(current.ItemId);
                        SharedFunctions.UpdateLog(this.UserId, this.ControlName + " - " + MethodBase.GetCurrentMethod().Name + " - " + XmlUtils.Serialize(current));
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
            }
        }

        private string GetSelectedShipMethod()
        {
            if (this.ddlShipMethod.Visible)
            {
                return this.ddlShipMethod.SelectedValue;
            }
            if (this._ShipType.ToUpper() == "PRD")
            {
                return Conversions.ToString(-1);
            }
            return Conversions.ToString(SharedFunctions.GetDefaultShipMethod(this.PortalId));
        }

        private void grdRange_DeleteCommand(object source, DataGridCommandEventArgs e)
        {
            ShipController controller = new ShipController();
            NB_Store_ShippingRatesInfo shippingRate = controller.GetShippingRate(this.PortalId, Conversions.ToInteger(e.Item.Cells[1].Text));
            controller.DeleteShippingRate(Conversions.ToInteger(e.Item.Cells[1].Text));
            if (shippingRate != null)
            {
                SharedFunctions.UpdateLog(this.UserId, this.ControlName + " - " + MethodBase.GetCurrentMethod().Name + " - " + XmlUtils.Serialize(shippingRate));
            }
            this.populateRangeDG();
        }

        private void grdRange_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            if (this._ShipType == "PRD")
            {
                DataGridItem item = e.Item;
                if (item.ItemType == ListItemType.Header)
                {
                    Label label = (Label) e.Item.FindControl("lbldgCostHeader");
                    label.Attributes["resourcekey"] = "dgBoxCost";
                }
                if (((item.ItemType == ListItemType.Item) | (item.ItemType == ListItemType.AlternatingItem)) | (item.ItemType == ListItemType.SelectedItem))
                {
                    TextBox box3 = (TextBox) e.Item.FindControl("txtWeight");
                    TextBox box2 = (TextBox) e.Item.FindControl("txtShipCost");
                    TextBox box = (TextBox) e.Item.FindControl("txtRange1");
                    if ((box3 != null) & (box2 != null))
                    {
                        CheckBox box4 = (CheckBox) e.Item.FindControl("chkDisable");
                        if (Versioned.IsNumeric(box3.Text) & Versioned.IsNumeric(box2.Text))
                        {
                            if ((decimal.Compare(Conversions.ToDecimal(box3.Text), decimal.Zero) == 0) & (decimal.Compare(Conversions.ToDecimal(box2.Text), decimal.Zero) == 0))
                            {
                                box4.Visible = false;
                                e.Item.Cells[0].Text = "";
                            }
                        }
                        else
                        {
                            box4.Visible = false;
                            e.Item.Cells[0].Text = "";
                        }
                    }
                }
            }
        }

        private void grdRange_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
        {
            this.grdRange.CurrentPageIndex = e.NewPageIndex;
            this.populateRangeDG();
        }

        private void loadCountryList()
        {
            SharedFunctions.populateCountryList(this.PortalId, this.ddlCountry, "", "XX - " + DotNetNuke.Services.Localization.Localization.GetString("Default", "/DesktopModules/NB_Store/App_LocalResources/NB_StoreGlobal"), "XX - " + DotNetNuke.Services.Localization.Localization.GetString("Default", "/DesktopModules/NB_Store/App_LocalResources/NB_StoreGlobal"), true);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (this.Request.QueryString["spg"] != null)
                {
                    switch (this.Request.QueryString["spg"].ToUpper())
                    {
                        case "QTY":
                            this._ShipType = this.Request.QueryString["spg"].ToUpper();
                            break;

                        case "PRC":
                            this._ShipType = this.Request.QueryString["spg"].ToUpper();
                            break;

                        case "WEI":
                            this._ShipType = this.Request.QueryString["spg"].ToUpper();
                            break;

                        case "PRD":
                            this._ShipType = this.Request.QueryString["spg"].ToUpper();
                            break;

                        case "COU":
                            this._ShipType = this.Request.QueryString["spg"].ToUpper();
                            break;

                        case "FRE":
                            this._ShipType = this.Request.QueryString["spg"].ToUpper();
                            break;
                    }
                    this._ShipMethodID = -1;
                    if (Versioned.IsNumeric(this.Request.QueryString["smethod"]))
                    {
                        this._ShipMethodID = Conversions.ToInteger(this.Request.QueryString["smethod"]);
                    }
                    else
                    {
                        this._ShipMethodID = SharedFunctions.GetDefaultShipMethod(this.PortalId);
                    }
                    if (!this.Page.IsPostBack)
                    {
                        this.pnlFree.Visible = false;
                        this.cmdDelete.Visible = false;
                        SharedFunctions.populateShipMethodList(this.ddlShipMethod, this.PortalId, this._ShipMethodID.ToString());
                        if (this.ddlShipMethod.Items.Count == 0)
                        {
                            this._ShipType = "ERR";
                        }
                        else if (this.ddlShipMethod.Items.Count == 1)
                        {
                            this.ddlShipMethod.Visible = false;
                        }
                        string str2 = this._ShipType.ToUpper();
                        if (str2 == "QTY")
                        {
                            this.grdRange.Columns[4].Visible = false;
                            this.grdRange.Columns[8].Visible = false;
                            this.grdRange.Columns[9].Visible = false;
                            this.pnlCountry.Visible = false;
                            this.pnlProduct.Visible = false;
                        }
                        else if (str2 == "PRC")
                        {
                            this.grdRange.Columns[4].Visible = false;
                            this.grdRange.Columns[8].Visible = false;
                            this.grdRange.Columns[9].Visible = false;
                            this.pnlCountry.Visible = false;
                            this.pnlProduct.Visible = false;
                        }
                        else if (str2 == "WEI")
                        {
                            this.grdRange.Columns[4].Visible = false;
                            this.grdRange.Columns[8].Visible = false;
                            this.grdRange.Columns[9].Visible = false;
                            this.pnlCountry.Visible = false;
                            this.pnlProduct.Visible = false;
                        }
                        else if (str2 == "PRD")
                        {
                            this.grdRange.Columns[5].Visible = false;
                            this.grdRange.Columns[6].Visible = false;
                            this.grdRange.Columns[8].Visible = true;
                            this.grdRange.Columns[9].Visible = true;
                            this.pnlCountry.Visible = false;
                            this.pnlProduct.Visible = true;
                            this.cmdNew.Visible = false;
                            this.lblShipMethod.Visible = false;
                            this.ddlShipMethod.Visible = false;
                            this._ShipMethodID = -1;
                            SharedFunctions.populateCategoryList(this.PortalId, this.ddlCategory, Conversions.ToString(-1), "All Categories", "");
                            this.populatePDefault();
                        }
                        else if (str2 == "COU")
                        {
                            this.grdRange.Columns[8].Visible = false;
                            this.grdRange.Columns[9].Visible = false;
                            this.pnlCountry.Visible = true;
                            this.pnlProduct.Visible = false;
                            this.cmdNew.Visible = false;
                            this.loadCountryList();
                            this.populateCDefault();
                        }
                        else if (str2 == "FRE")
                        {
                            this.pnlCountry.Visible = false;
                            this.pnlProduct.Visible = false;
                            this.pnlRange.Visible = false;
                            this.pnlFree.Visible = true;
                            this.cmdDelete.Visible = true;
                            this.cmdNew.Visible = false;
                            this.populateFDefault();
                        }
                        else
                        {
                            this.pnlEdit.Visible = false;
                        }
                        if (this._ShipType != "PRD")
                        {
                            this.populateRangeDG();
                        }
                    }
                }
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exc = exception1;
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException((PortalModuleBase) this, exc);
                ProjectData.ClearProjectError();
            }
        }

        private void populateCDefault()
        {
            ShipController controller = new ShipController();
            NB_Store_ShippingRatesInfo current = new NB_Store_ShippingRatesInfo();
            ArrayList list = controller.GetShippingRateList(this.PortalId, "DCO", SharedFunctions.GetCurrentCulture(), "", this._ShipMethodID);
            if (list == null)
            {
                this.txtCDefault.Text = "0";
                this.lblCDefaultID.Text = "0";
            }
            else if (list.Count == 0)
            {
                this.txtCDefault.Text = "0";
                this.lblCDefaultID.Text = "0";
            }
            else
            {
                IEnumerator enumerator=null;
                try
                {
                    enumerator = list.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        current = (NB_Store_ShippingRatesInfo) enumerator.Current;
                        this.txtCDefault.Text = current.ShipCost.ToString();
                        this.lblCDefaultID.Text = current.ItemId.ToString();
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
            }
        }

        private void populateFDefault()
        {
            ShipController controller = new ShipController();
            NB_Store_ShippingRatesInfo current = new NB_Store_ShippingRatesInfo();
            ArrayList list = controller.GetShippingRateList(this.PortalId, "FRE", SharedFunctions.GetCurrentCulture(), "", this._ShipMethodID);
            if (list == null)
            {
                this.txtFreeShip.Text = "0";
                this.lblFreeShip.Text = "0";
            }
            else if (list.Count == 0)
            {
                this.txtFreeShip.Text = "0";
                this.lblFreeShip.Text = "0";
            }
            else
            {
                IEnumerator enumerator=null;
                try
                {
                    enumerator = list.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        current = (NB_Store_ShippingRatesInfo) enumerator.Current;
                        this.txtFreeShip.Text = current.ShipCost.ToString();
                        this.lblFreeShip.Text = current.ItemId.ToString();
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
            }
            this.txtFreeShipList.Text = SharedFunctions.GetStoreSetting(this.PortalId, "shipfree.list", "None", true);
        }

        private void populatePDefault()
        {
            ShipController controller = new ShipController();
            NB_Store_ShippingRatesInfo current = new NB_Store_ShippingRatesInfo();
            ArrayList list = controller.GetShippingRateList(this.PortalId, "DPO", SharedFunctions.GetCurrentCulture(), "", -1);
            if (list == null)
            {
                this.txtPDefault.Text = "0";
                this.lblPDefaultID.Text = "0";
            }
            else if (list.Count == 0)
            {
                this.txtPDefault.Text = "0";
                this.lblPDefaultID.Text = "0";
            }
            else
            {
                IEnumerator enumerator=null;
                try
                {
                    enumerator = list.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        current = (NB_Store_ShippingRatesInfo) enumerator.Current;
                        this.txtPDefault.Text = Conversions.ToString(current.ProductWeight);
                        this.lblPDefaultID.Text = current.ItemId.ToString();
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
            }
        }

        private void populateRangeDG()
        {
            ArrayList list;
            ShipController controller = new ShipController();
            if (this._ShipType.ToUpper() == "PRD")
            {
                list = controller.GetShippingRateList(this.PortalId, this._ShipType.ToUpper(), SharedFunctions.GetCurrentCulture(), this.txtSearch.Text, Conversions.ToInteger(this.ddlCategory.SelectedValue), -1);
            }
            else
            {
                list = controller.GetShippingRateList(this.PortalId, this._ShipType.ToUpper(), SharedFunctions.GetCurrentCulture(), this.txtSearch.Text, this._ShipMethodID);
            }
            this.grdRange.DataSource = list;
            this.grdRange.DataBind();
        }

        private void updateRangeDG()
        {
            try
            {
                if (this.Page.IsValid)
                {
                    NB_Store_ShippingRatesInfo info;
                    IEnumerator enumerator=null;
                    ShipController controller = new ShipController();
                    try
                    {
                        enumerator = this.grdRange.Items.GetEnumerator();
                        while (enumerator.MoveNext())
                        {
                            DataGridItem current = (DataGridItem) enumerator.Current;
                            info = new NB_Store_ShippingRatesInfo {
                                ShipMethodID = this._ShipMethodID,
                                PortalID = this.PortalId,
                                ItemId = Conversions.ToInteger(current.Cells[1].Text),
                                ObjectId = Conversions.ToInteger(current.Cells[2].Text),
                                ShipType = current.Cells[3].Text
                            };
                            if (current.Cells[4].Visible)
                            {
                                info.Description = current.Cells[4].Text;
                            }
                            else
                            {
                                info.Description = "";
                            }
                            try
                            {
                                if (this._ShipType.ToUpper() == "PRD")
                                {
                                    info.Range1 = Conversions.ToDecimal(((TextBox) current.FindControl("txtBox")).Text);
                                }
                                else
                                {
                                    info.Range1 = Conversions.ToDecimal(((TextBox) current.FindControl("txtRange1")).Text);
                                }
                            }
                            catch (Exception exception1)
                            {
                                ProjectData.SetProjectError(exception1);
                                Exception exception = exception1;
                                info.Range1 = decimal.Zero;
                                ProjectData.ClearProjectError();
                            }
                            try
                            {
                                info.Range2 = Conversions.ToDecimal(((TextBox) current.FindControl("txtRange2")).Text);
                            }
                            catch (Exception exception9)
                            {
                                ProjectData.SetProjectError(exception9);
                                Exception exception2 = exception9;
                                info.Range2 = decimal.Zero;
                                ProjectData.ClearProjectError();
                            }
                            try
                            {
                                info.ShipCost = Conversions.ToDecimal(((TextBox) current.FindControl("txtShipCost")).Text);
                            }
                            catch (Exception exception10)
                            {
                                ProjectData.SetProjectError(exception10);
                                Exception exception3 = exception10;
                                info.ShipCost = decimal.Zero;
                                ProjectData.ClearProjectError();
                            }
                            try
                            {
                                info.ProductWeight = Conversions.ToDecimal(((TextBox) current.FindControl("txtWeight")).Text);
                            }
                            catch (Exception exception11)
                            {
                                ProjectData.SetProjectError(exception11);
                                Exception exception4 = exception11;
                                info.ProductWeight = decimal.Zero;
                                ProjectData.ClearProjectError();
                            }
                            info.Disable = ((CheckBox) current.FindControl("chkDisable")).Checked;
                            if (info.ShipType == "PRD")
                            {
                                if ((decimal.Compare(info.ShipCost, decimal.Zero) > 0) | (decimal.Compare(info.ProductWeight, decimal.Zero) > 0))
                                {
                                    info.ShipMethodID = -1;
                                    controller.UpdateObjShippingRate(info);
                                }
                            }
                            else
                            {
                                controller.UpdateObjShippingRate(info);
                            }
                            SharedFunctions.UpdateLog(this.UserId, this.ControlName + " - " + MethodBase.GetCurrentMethod().Name + " - " + XmlUtils.Serialize(info));
                        }
                    }
                    finally
                    {
                        if (enumerator is IDisposable)
                        {
                            (enumerator as IDisposable).Dispose();
                        }
                    }
                    if (this.pnlCountry.Visible)
                    {
                        info = new NB_Store_ShippingRatesInfo {
                            ShipMethodID = this._ShipMethodID,
                            ItemId = Conversions.ToInteger(this.lblCDefaultID.Text),
                            ObjectId = -1,
                            Range1 = decimal.Zero,
                            Range2 = decimal.Zero
                        };
                        try
                        {
                            info.ShipCost = Conversions.ToDecimal(this.txtCDefault.Text);
                        }
                        catch (Exception exception12)
                        {
                            ProjectData.SetProjectError(exception12);
                            Exception exception5 = exception12;
                            info.ShipCost = decimal.Zero;
                            ProjectData.ClearProjectError();
                        }
                        info.ShipType = "DCO";
                        info.Description = "Country Default";
                        info.ProductWeight = decimal.Zero;
                        info.ProductHeight = decimal.Zero;
                        info.ProductLength = decimal.Zero;
                        info.ProductWidth = decimal.Zero;
                        info.PortalID = this.PortalId;
                        controller.UpdateObjShippingRate(info);
                        SharedFunctions.UpdateLog(this.UserId, this.ControlName + " - " + MethodBase.GetCurrentMethod().Name + " - " + XmlUtils.Serialize(info));
                    }
                    if (this.pnlProduct.Visible)
                    {
                        info = new NB_Store_ShippingRatesInfo {
                            ShipMethodID = -1,
                            ItemId = Conversions.ToInteger(this.lblPDefaultID.Text),
                            ObjectId = -1,
                            Range1 = Conversions.ToDecimal("0"),
                            Range2 = Conversions.ToDecimal("0")
                        };
                        try
                        {
                            info.ProductWeight = Conversions.ToDecimal(this.txtPDefault.Text);
                        }
                        catch (Exception exception13)
                        {
                            ProjectData.SetProjectError(exception13);
                            Exception exception6 = exception13;
                            info.ProductWeight = decimal.Zero;
                            ProjectData.ClearProjectError();
                        }
                        info.ShipType = "DPO";
                        info.Description = "Product Weight Default";
                        info.ShipCost = decimal.Zero;
                        info.ProductHeight = decimal.Zero;
                        info.ProductLength = decimal.Zero;
                        info.ProductWidth = decimal.Zero;
                        info.PortalID = this.PortalId;
                        controller.UpdateObjShippingRate(info);
                        SharedFunctions.UpdateLog(this.UserId, this.ControlName + " - " + MethodBase.GetCurrentMethod().Name + " - " + XmlUtils.Serialize(info));
                    }
                    if (this.pnlFree.Visible)
                    {
                        info = new NB_Store_ShippingRatesInfo {
                            ShipMethodID = this._ShipMethodID,
                            ItemId = Conversions.ToInteger(this.lblFreeShip.Text),
                            ObjectId = -1,
                            Range1 = decimal.Zero,
                            Range2 = decimal.Zero
                        };
                        try
                        {
                            info.ShipCost = Conversions.ToDecimal(this.txtFreeShip.Text);
                        }
                        catch (Exception exception14)
                        {
                            ProjectData.SetProjectError(exception14);
                            Exception exception7 = exception14;
                            info.ShipCost = decimal.Zero;
                            ProjectData.ClearProjectError();
                        }
                        info.ProductWeight = decimal.Zero;
                        info.ShipType = "FRE";
                        info.Description = "Free Shipping Level";
                        info.ProductHeight = decimal.Zero;
                        info.ProductLength = decimal.Zero;
                        info.ProductWidth = decimal.Zero;
                        info.PortalID = this.PortalId;
                        controller.UpdateObjShippingRate(info);
                        SharedFunctions.UpdateLog(this.UserId, this.ControlName + " - " + MethodBase.GetCurrentMethod().Name + " - " + XmlUtils.Serialize(info));
                        SharedFunctions.SetStoreSetting(this.PortalId, "shipfree.list", this.txtFreeShipList.Text, "None", false);
                    }
                    if (this._ShipType == "PRD")
                    {
                        this.populateRangeDG();
                    }
                    else
                    {
                        this.Response.Redirect(this.Request.Url.ToString());
                    }
                }
            }
            catch (Exception exception15)
            {
                ProjectData.SetProjectError(exception15);
                Exception exc = exception15;
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException((PortalModuleBase) this, exc);
                ProjectData.ClearProjectError();
            }
        }

        protected virtual LinkButton cmdAddCounty
        {
            get
            {
                return this._cmdAddCounty;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                EventHandler handler = new EventHandler(this.cmdAddCounty_Click);
                if (this._cmdAddCounty != null)
                {
                    this._cmdAddCounty.Click -= handler;
                }
                this._cmdAddCounty = value;
                if (this._cmdAddCounty != null)
                {
                    this._cmdAddCounty.Click += handler;
                }
            }
        }

        protected virtual LinkButton cmdDelete
        {
            get
            {
                return this._cmdDelete;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                EventHandler handler = new EventHandler(this.cmdDelete_Click);
                if (this._cmdDelete != null)
                {
                    this._cmdDelete.Click -= handler;
                }
                this._cmdDelete = value;
                if (this._cmdDelete != null)
                {
                    this._cmdDelete.Click += handler;
                }
            }
        }

        protected virtual LinkButton cmdNew
        {
            get
            {
                return this._cmdNew;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                EventHandler handler = new EventHandler(this.cmdNew_Click);
                if (this._cmdNew != null)
                {
                    this._cmdNew.Click -= handler;
                }
                this._cmdNew = value;
                if (this._cmdNew != null)
                {
                    this._cmdNew.Click += handler;
                }
            }
        }

        protected virtual LinkButton cmdSearch
        {
            get
            {
                return this._cmdSearch;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                EventHandler handler = new EventHandler(this.cmdSearch_Click);
                if (this._cmdSearch != null)
                {
                    this._cmdSearch.Click -= handler;
                }
                this._cmdSearch = value;
                if (this._cmdSearch != null)
                {
                    this._cmdSearch.Click += handler;
                }
            }
        }

        protected virtual LinkButton cmdUpdate
        {
            get
            {
                return this._cmdUpdate;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                EventHandler handler = new EventHandler(this.cmdUpdate_Click);
                if (this._cmdUpdate != null)
                {
                    this._cmdUpdate.Click -= handler;
                }
                this._cmdUpdate = value;
                if (this._cmdUpdate != null)
                {
                    this._cmdUpdate.Click += handler;
                }
            }
        }

        protected virtual CompareValidator CompareValidator1
        {
            get
            {
                return this._CompareValidator1;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._CompareValidator1 = value;
            }
        }

        protected virtual DropDownList ddlCategory
        {
            get
            {
                return this._ddlCategory;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._ddlCategory = value;
            }
        }

        protected virtual DropDownList ddlCountry
        {
            get
            {
                return this._ddlCountry;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._ddlCountry = value;
            }
        }

        protected virtual DropDownList ddlShipMethod
        {
            get
            {
                return this._ddlShipMethod;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                EventHandler handler = new EventHandler(this.ddlShipMethod_SelectedIndexChanged);
                if (this._ddlShipMethod != null)
                {
                    this._ddlShipMethod.SelectedIndexChanged -= handler;
                }
                this._ddlShipMethod = value;
                if (this._ddlShipMethod != null)
                {
                    this._ddlShipMethod.SelectedIndexChanged += handler;
                }
            }
        }

        protected virtual DataGrid grdRange
        {
            get
            {
                return this._grdRange;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                DataGridPageChangedEventHandler handler = new DataGridPageChangedEventHandler(this.grdRange_PageIndexChanged);
                DataGridCommandEventHandler handler2 = new DataGridCommandEventHandler(this.grdRange_DeleteCommand);
                DataGridItemEventHandler handler3 = new DataGridItemEventHandler(this.grdRange_ItemDataBound);
                if (this._grdRange != null)
                {
                    this._grdRange.PageIndexChanged -= handler;
                    this._grdRange.DeleteCommand -= handler2;
                    this._grdRange.ItemDataBound -= handler3;
                }
                this._grdRange = value;
                if (this._grdRange != null)
                {
                    this._grdRange.PageIndexChanged += handler;
                    this._grdRange.DeleteCommand += handler2;
                    this._grdRange.ItemDataBound += handler3;
                }
            }
        }

        protected virtual Label lblCDefaultID
        {
            get
            {
                return this._lblCDefaultID;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._lblCDefaultID = value;
            }
        }

        protected virtual Label lblFreeShip
        {
            get
            {
                return this._lblFreeShip;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._lblFreeShip = value;
            }
        }

        protected virtual Label lblPDefaultID
        {
            get
            {
                return this._lblPDefaultID;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._lblPDefaultID = value;
            }
        }

        protected virtual Label lblShipMethod
        {
            get
            {
                return this._lblShipMethod;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._lblShipMethod = value;
            }
        }

        protected virtual UserControl plCDefault
        {
            get
            {
                return this._plCDefault;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._plCDefault = value;
            }
        }

        protected virtual UserControl plFreeShip
        {
            get
            {
                return this._plFreeShip;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._plFreeShip = value;
            }
        }

        protected virtual UserControl plFreeShipList
        {
            get
            {
                return this._plFreeShipList;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._plFreeShipList = value;
            }
        }

        protected virtual UserControl plPDefault
        {
            get
            {
                return this._plPDefault;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._plPDefault = value;
            }
        }

        protected virtual UserControl plRangeHelp
        {
            get
            {
                return this._plRangeHelp;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._plRangeHelp = value;
            }
        }

        protected virtual Panel pnlCountry
        {
            get
            {
                return this._pnlCountry;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._pnlCountry = value;
            }
        }

        protected virtual Panel pnlEdit
        {
            get
            {
                return this._pnlEdit;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._pnlEdit = value;
            }
        }

        protected virtual Panel pnlFree
        {
            get
            {
                return this._pnlFree;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._pnlFree = value;
            }
        }

        protected virtual Panel pnlProduct
        {
            get
            {
                return this._pnlProduct;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._pnlProduct = value;
            }
        }

        protected virtual Panel pnlRange
        {
            get
            {
                return this._pnlRange;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._pnlRange = value;
            }
        }

        protected virtual CompareValidator revCCDefault
        {
            get
            {
                return this._revCCDefault;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._revCCDefault = value;
            }
        }

        protected virtual CompareValidator revPCDefault
        {
            get
            {
                return this._revPCDefault;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._revPCDefault = value;
            }
        }

        protected virtual TextBox txtCDefault
        {
            get
            {
                return this._txtCDefault;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._txtCDefault = value;
            }
        }

        protected virtual TextBox txtFreeShip
        {
            get
            {
                return this._txtFreeShip;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._txtFreeShip = value;
            }
        }

        protected virtual TextBox txtFreeShipList
        {
            get
            {
                return this._txtFreeShipList;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._txtFreeShipList = value;
            }
        }

        protected virtual TextBox txtPDefault
        {
            get
            {
                return this._txtPDefault;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._txtPDefault = value;
            }
        }

        protected virtual TextBox txtSearch
        {
            get
            {
                return this._txtSearch;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._txtSearch = value;
            }
        }
    }
}

